import logging

# 消息格式化
__fmt = logging.Formatter('%(asctime)-15s %(levelname)s %(filename)s %(lineno)d %(process)d %(thread)d %(message)s')

# 控制台日志
__console_handler = logging.StreamHandler()
__console_handler.setLevel(logging.DEBUG)
__console_handler.setFormatter(__fmt)
# 文件日志
__file_handler = logging.FileHandler('../yysautomatic.log', encoding='UTF-8')
__file_handler.setLevel(logging.DEBUG)
__file_handler.setFormatter(__fmt)


def get_logger(name):
    logger = logging.getLogger(name)
    logger.addHandler(__console_handler)
    logger.addHandler(__file_handler)
    logger.setLevel(logging.DEBUG)
    return logger
